import TYPE from "../type";


function indexReducer(state={banner:[],recommend:[],activity:[],productlist:[],page:1,isfinish:false},action){
    state = JSON.parse(JSON.stringify(state));
    switch(action.type){
   	    case TYPE.GET_BANNER:
   	        state.banner = action.data;
            return state;
        case TYPE.GET_RECOMMEND:
   	        state.recommend = action.data;
            return state; 
        case TYPE.GET_ACTIVITY:
            state.activity = action.data;
            return state;
        case TYPE.GET_PRODUCTLIST:
            state.page++;
            state.productlist = [...state.productlist,...action.data];
            return state; 
        case TYPE.SET_ISFINISH:
            state.isfinish = true;
            return state;
        default:
            return state;
    }

}


export default indexReducer;